/**
 *  @Description 生成编辑、新增、详情的路由
 *  @param {string} [title=""] 前缀名称
 *  @param {function} extra 额外扩展
 *  @return {function}
 */

const actionMap = {
  add: "新增",
  edit: "编辑",
  detail: "详情"
};

export function metaBreadcrumb(title = "", extra) {
  return (route = {}) => {
    const { params, meta } = route;
    const action = params?.action;
    if (title) {
      return `${title}${actionMap[action] || ""}`;
    }
    return extra?.(route);
  };
}
